﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        Elevator first = new Elevator();
        public Form1()
        {
            InitializeComponent();
			
			first.mutateTop(20);
            first.mutateBottom(0);
            first.mutateFloor(0);
			first.location.y = (first.viewTop()-first.viewFloor())*10;
            first.mutateDefault(10);
            if (floorStandard.Checked)
            {
                label4.Text = "current value: " + (first.viewTop()+1).ToString();
                label5.Text = "current value: " + (first.viewBottom()+1).ToString();
                label6.Text = "current value: " + (first.viewDefault()+1).ToString();
                label7.Text = "current floor: " + (first.viewFloor()+1).ToString();
            }
            else
            {
                label4.Text = "current value: " + first.viewTop().ToString();
                label5.Text = "current value: " + first.viewBottom().ToString();
                label6.Text = "current value: " + first.viewDefault().ToString();
                label7.Text = "current floor: " + first.viewFloor().ToString();
            }
                //first.mutateFloorDiff(6);

        }
        protected override void OnPaint(PaintEventArgs e)
        {
            System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Red);
            System.Drawing.Pen myPen2 = new System.Drawing.Pen(System.Drawing.Color.Blue);
			System.Drawing.Graphics formGraphics;
            formGraphics = CreateGraphics();
            
            for (int i = 0; i <= (first.viewTop() - first.viewBottom()); i++)
                formGraphics.DrawEllipse(myPen, 0, i * 10, 10, 10);
			first.drawLoc(formGraphics, myPen2, first.doorsOpen);
            myPen.Dispose();
            formGraphics.Dispose();
        }

        private void goTo_Click(object sender, EventArgs e)
        {

            if(floorStandard.Checked)
                first.goToFloor((Int32.Parse(sendFloor.Text)-1));
            else
                first.goToFloor(Int32.Parse(sendFloor.Text));
            things();
            sendFloor.Text = "";
            if (floorStandard.Checked)
                label7.Text = "current floor: " + (first.viewFloor()+1).ToString();
            else
                label7.Text = "current floor: " + first.viewFloor().ToString();
        }
        public void things()
        {
            do
            {
                first.move();
                System.Threading.Thread.Sleep(100);
                Invalidate();
                Update();

            } while (first.doorsOpen == false);
        }

        private void commit_Click(object sender, EventArgs e)
        {
            if (floorStandard.Checked)
            {
                    first.mutateBottom(Int32.Parse(bottomFloor.Text)-1);
                    first.mutateTop(Int32.Parse(topFloor.Text)-1);
                    first.mutateDefault(Int32.Parse(defaultFloor.Text)-1);
					first.mutateFloor(Int32.Parse(defaultFloor.Text)-1);
					first.location.y = (first.viewTop() - first.viewFloor())*10;
					
			}
            else
            {
                first.mutateBottom(Int32.Parse(bottomFloor.Text));
                first.mutateTop(Int32.Parse(topFloor.Text));
                first.mutateDefault(Int32.Parse(defaultFloor.Text));
				first.mutateFloor(Int32.Parse(defaultFloor.Text));
				first.location.y = (first.viewTop() - first.viewFloor())*10;
				
            }
            if (floorStandard.Checked)
            {
                label4.Text = "current value: " + (first.viewTop() + 1).ToString();
                label5.Text = "current value: " + (first.viewBottom() + 1).ToString();
                label6.Text = "current value: " + (first.viewDefault() + 1).ToString();
				label7.Text = "current floor: " + (first.viewFloor() + 1).ToString();
            }
            else
            {
                label4.Text = "current value: " + first.viewTop().ToString();
                label5.Text = "current value: " + first.viewBottom().ToString();
                label6.Text = "current value: " + first.viewDefault().ToString();
				label7.Text = "current floor: " + (first.viewFloor()).ToString();
            }
            Invalidate();
			Update();
        }

        private void floorStandard_CheckedChanged(object sender, EventArgs e)
        {
            if (floorStandard.Checked)
            {
                label4.Text = "current value: " + (first.viewTop() + 1).ToString();
                label5.Text = "current value: " + (first.viewBottom() + 1).ToString();
                label6.Text = "current value: " + (first.viewDefault() + 1).ToString();
                label7.Text = "current floor: " + (first.viewFloor() + 1).ToString();
            }
            else
            {
                label4.Text = "current value: " + first.viewTop().ToString();
                label5.Text = "current value: " + first.viewBottom().ToString();
                label6.Text = "current value: " + first.viewDefault().ToString();
                label7.Text = "current floor: " + first.viewFloor().ToString();
            }
            Invalidate();
        }





    }

}



